How mirai and crew Are Powering the Next Generation of Parallel Computing in R
Hibiki AI Limited, Eli Lilly and Company
2024-07-09
みらい / mI ˈ ra ˈ i: /
But what’s so special about this? …
Request by R Core (Luke Tierney) at R Project Sprint 2023
mirai added as the first alternative communications backend for the base parallel packagelibrary(shiny)
library(bslib)
library(mirai)
ui <- page_fluid(
numericInput("n", "Sample size (n)", 100),
numericInput("delay", "Seconds to take for plot", 5),
input_task_button("btn", "Plot uniform distribution"),
plotOutput("plot")
)
server <- function(input, output, session) {
task <- ExtendedTask$new(
function(...) mirai({Sys.sleep(y); runif(x)}, ...)
) |> bind_task_button("btn")
observeEvent(input$btn, task$invoke(x = input$n, y = input$delay))
output$plot <- renderPlot(hist(task$result()))
}
app <- shinyApp(ui = ui, server = server)
with(daemons(3), runApp(app))miraicrew?mirai to distributed computing environments.
R6 interface for tasks.
crew.pull-left[
mirai developer interface: daemon(), nextget(), saisei() etc.R6 class system for the controller interface.]
.pull-right[
]
R6 classes| Class | About |
|---|---|
| Controller group | Interface for many controllers. |
| Controller | Central task interface. |
| Tasks | List of mirai task objects. |
| Client | mirai TCP connection hub. |
| Relay | Coordinate mirai synchronization primitives. |
| Launcher | Launches workers. Subclasses for plugins. |
| Async | Parallelize worker launches. |
R6 object compositionmirai tasks, different interfaceslides available at https://shikokuchuo.net/user2024-conference